const Router = require('koa-router')  //注意：引入的方式

const { auth } = require('../middleware/auth.middleware')
const { articleValidator, articleIdValidator, hasArticle, articleIdHas} = require('../middleware/article.middleware')
const {search, add_article, edit_article, del_article,publish_article } = require('../controller/article.controller')
const router = new Router({ prefix: '/article' })

// 查询
router.post('/articleInfo', auth, search)
// 新增
router.post('/add', auth, articleValidator, hasArticle, add_article)
// 修改
router.post('/edit', auth, articleIdValidator, edit_article)
// 删除
router.post('/del', auth, articleIdValidator, articleIdHas, del_article);
// 发布/ 取消
router.post('/publish', auth, publish_article);


module.exports = router